package com.hx.er.action.admin.msg;

import org.springframework.beans.factory.annotation.Autowired;

import com.hx.er.action.base.ErAdminAction;
import com.hx.er.bean.detail.MessageDetailBean;
import com.hx.er.service.admin.IAdminMsgService;

public class AdminMsgIgnoreAction extends ErAdminAction {
	// 序列化ID
	private static final long serialVersionUID = -1127474451530316813L;

	private long msgId;
	private MessageDetailBean msgDetailBean;

	@Autowired
	private IAdminMsgService adminMsgService;

	public String init() {
		this.initPage();
		return SUCCESS;
	}

	public String ignore() {
		this.msgDetailBean.setMsgId(this.msgId);
		this.msgDetailBean.setUpdateUserId(super.getUserInfoLogin().getUserId());

		int count = this.adminMsgService.ignoreMsg(this.msgDetailBean);

		if (count == 0) {
			this.initPage();
			this.addActionError(super.getText(OPERATION_FAILURE_MSG));
			return INPUT;
		} else {
			// 缓存中删除该餐厅
			this.addActionMessage(super.getText(OPERATION_SUCCESS_MSG));
			return SUCCESS;
		}
	}

	private void initPage() {
		// 查询餐馆信息
		this.msgDetailBean = this.adminMsgService.getMsgDetailAliveById(this.msgId);
	}

	public long getMsgId() {
		return msgId;
	}

	public void setMsgId(long msgId) {
		this.msgId = msgId;
	}

	public MessageDetailBean getMsgDetailBean() {
		return msgDetailBean;
	}

	public void setMsgDetailBean(MessageDetailBean msgDetailBean) {
		this.msgDetailBean = msgDetailBean;
	}

}
